//go:build dev

package main

import (
	"gitee.com/micro-plat/sso/ssov5"
	"github.com/micro-plat/hydra"
	"github.com/micro-plat/hydra/conf/server/api"
	"github.com/micro-plat/hydra/conf/server/auth"
	"github.com/micro-plat/hydra/conf/server/auth/jwt"
	"github.com/micro-plat/hydra/conf/server/header"
	"github.com/micro-plat/hydra/conf/server/processor"
)

//初始化配置
func init() {
	hydra.OnReady(func() error {

		//配置共有配置
		hydra.Conf.Vars().DB().Custom("db", "encrypt:cbc/pkcs5:0359e6dbb6f414c8f9561280089a23e97d3864eec5cd7efc4fc6948c5751c87b0f7bc22276e522414422e392f7e2f6f43f8575b5ddaa40ae1710fe4db660899a6a1991dd18e4dd34e23749a3dac02f3a70438c22b5f164f6971f7ae4306453a128b3f88b69c63905db91ebbbfc5d1c3c91fb9b32717d489667a390c1421878ca3823cd45d75e8bda42c32033a20e61076565c5027616ffb6ff28923fba3d99fd74d2d2e585aef8a0")

		//登录的界面配置
		hydra.Conf.Web("8089", api.WithTimeout(300, 300)).
			Processor(processor.WithServicePrefix("/api")).
			Header(header.WithCrossDomain()).
			Jwt(jwt.WithMode("HS512"),
				jwt.WithSecret("bf8f3171946d8d5a13cca23aa6080c8e"),
				jwt.WithExpireAt(36000),
				jwt.WithAuthURL("/login"),
				jwt.WithHeader(),
				jwt.WithExcludes(auth.GetExcludes()...),
			)

		if err := ssov5.Bind(hydra.S.Web, "http://localhost:6689",
			"sso5", "a519dae547a11824b6fac1625dcf04a3", "api"); err != nil {
			return err
		}
		return nil

	})
}
